import request from '@/utils/request'

// 查询投资主体列表
export function listDealInvestment(query) {
  return request({
    url: '/investment/dealInvestment/list',
    method: 'post',
    data: query
  })
}

// 查询投资主体列表 不分页
export function listDealInvestmentAll(query) {
  return request({
    url: '/investment/dealInvestment/listAll',
    method: 'post',
    data: query
  })
}

// 查询投资主体列表-根据投资主体名称
export function listDealInvestmentByInvestName(investName) {
  return request({
    url: '/investment/dealInvestment/findListByInvestmentName?investName=' + investName,
    method: 'get'
  })
}

export function getInvestmentByName(query) {
  return request({
    url: '/investment/dealInvestment/getInvestmentByName',
    method: 'get',
    params: query
  })
}

// 查询投资主体详细
export function getDealInvestment(id) {
  return request({
    url: '/investment/dealInvestment/' + id,
    method: 'get'
  })
}

// 保存投资主体
export function saveDealInvestment(data) {
  return request({
    url: '/investment/dealInvestment/save',
    method: 'post',
    data: data
  })
}

// 删除投资主体
export function delDealInvestment(id) {
  return request({
    url: '/investment/dealInvestment/' + id,
    method: 'delete'
  })
}

// 导出投资主体
export function exportDealInvestment(query) {
  return request({
    url: '/investment/dealInvestment/export',
    method: 'get',
    params: query
  })
}

// 根据项目ID获取当前项目全部投资主体
export function findByDealId(dealId) {
  return request({
    url: '/investment/dealInvestment/findByDealId/' + dealId,
    method: 'get'
  })
}

export function findByDealIdToValuation(dealId, valuationTime) {
  if (!valuationTime || valuationTime === '') {
    valuationTime = 2099 + '-' + 12 + '-' + 31
  }
  return request({
    url: '/investment/dealInvestment/findByDealIdToValuation/' + dealId + '/' + valuationTime,
    method: 'get'
  })
}

// 投后视图  投资信息
export function getByIdFindPostInvestmentInformation(dealId, companyId, investId) {
  return request({
    url: '/investment/dealInvestment/getByIdFindPostInvestmentInformation/' + dealId + '/' + companyId + '/' + investId,
    method: 'get'
  })
}
// 投后视图  投资信息
export function getByIdBfDefaultBaseInfo(dealId, companyId) {
  return request({
    url: '/investment/dealInvestment/getByIdBfDefaultBaseInfo/' + dealId + '/' + companyId,
    method: 'get'
  })
}

// 上市项目证券账户持仓信息
export function findByDealIdAndInvestorId(dealId, investorId) {
  return request({
    url: '/investment/dealInvestment/findByDealIdAndInvestorId/' + dealId + '/' + investorId,
    method: 'get'
  })
}

// 投资期 投资情况 饼状图
export function investmentPieChart(fundId) {
  return request({
    url: '/investment/dealInvestment/investmentPieChart/' + fundId,
    method: 'get'
  })
}

// 根据公司ID获取使用该公司项目的全部投资主体
export function findByCompanyId(companyId) {
  return request({
    url: '/investment/dealInvestment/findByCompanyId/' + companyId,
    method: 'get'
  })
}

export function getCashFlow(investorId, dealId) {
  return request({
    url: '/investment/dealInvestment/getCashFlow/' + investorId + '/' + dealId,
    method: 'get'
  })
}

export function getDealInvestmentIrrHistory(data) {
  return request({
    url: '/investment/dealInvestment/getDealInvestmentIrrHistory',
    method: 'post',
    data: data
  })
}

// 获取外网最新汇率
export function getWebRate(target, source, time) {
  // 确保有值请求不报错
  if (source === undefined || source === null || source === '') {
    source = '-999'
  }
  if (target === undefined || target === null || target === '') {
    target = '-998'
  }
  if (time === undefined || time === null || time === '') {
    time = new Date()
  }
  return request({
    url: '/investment/dealInvestment/exchangeConvert/' + target + '/' + source + '/' + time,
    method: 'get'
  })
}

export function findListByInvestorIds(data) {
  return request({
    url: '/investment/dealInvestment/findListByInvestorIds',
    method: 'post',
    data: data
  })
}
